<style lang="scss" scoped>
    .input-block{
        position: relative;
        width: 710px;
        
    }   

    .input-label{
        width: 100%;
        height:17px; text-align: left;
        color:rgba(48,54,65,1);
        line-height:17px;
        margin-bottom: 10px;
        font-size: 12px;
    }

    .input{
        width: 100%;
        height: 50px;
        padding: 15px 20px;
        box-sizing: border-box;
        color:rgba(48,54,65,1);
        font-size: 14px;
        border:1px solid rgba(200,199,204,1);
        outline: none; background: #fff;
    }

    .focus{
        border-color: red; 
    }

    .icon{
        position: absolute;
        right: 15px; bottom: 18px;
    }
</style>
<template>
    <div class="input-block" ref="block">
        <div class="input-label">{{label}}</div>
        <input class="input"
            ref="dom" 
            :value="value" 
            @input="input" 
            :type="type"
            :class="{'focus': focus}"
            :placeholder="placeholder"/>
            <i class="el-icon-arrow-down icon" v-if="show"></i>
    </div>
</template>
<script>
    export default {
        data () {
            return {
                show: false
            }
        },
        mounted () {
            if (this.$refs.block.hasAttribute('readonly')) {
                this.show = true
                this.$refs.dom.setAttribute('readonly', 'readonly')
                this.$refs.dom.style.cursor= 'pointer'
            } else {
                this.$refs.dom.removeAttribute('readonly')
            }
            
        },
        watch: {
            focus (v) {
                if (v) {
                    this.$refs.dom.focus()
                }   
            }
        },
        props: {
            value: '',
            type: {
                type: String,
                default () {
                    return 'text'
                }
            },
            placeholder: {
                type: String,
                default () {
                    return ''
                }
            },
            label: {
                type: String,
                default () {
                    return ' '
                }
            },
            focus: {
                type: Boolean,
                default: false
            }
        },
        methods: {
            input (e) {
                this.$emit('input', e.target.value)
            }
        }
    }
</script>

